package com.sjhang.controller;


import com.shenmazong.vo.ListParamVo;
import com.sjhang.entity.TbOutline;
import com.sjhang.service.TbOutlineService;
import com.sjhang.utils.OssUploadTemplate;
import com.sjhang.utils.ResultResponse;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 大纲表-
 前端控制器
 *
 */
@Api(tags = {"大纲接口"})
@RestController
@RequestMapping("/tbOutline")
public class TbOutlineController {

    @Resource
    private TbOutlineService tbOutlineService;

    @Autowired
    private OssUploadTemplate ossUploadTemplate;

    /***
     * @description 查看所有大纲
     * @params [listParamVo]
     */
    @PostMapping("/selectTBOutline")
    public ResultResponse selectTBOutline(@RequestBody ListParamVo listParamVo){
        return tbOutlineService.selectTBOutline(listParamVo);
    }

    /***
     * @description 对阶段新增某一个大纲
     * @params [listParamVo]
     */
    @PostMapping("/insertTbOutLine")
    public ResultResponse insertTbOutLine(@RequestBody TbOutline tbOutline){
        return tbOutlineService.insertTbOutLine(tbOutline);
    }

    /***
     * @description 对大纲名称进行修改
     * @params [listParamVo]
     */
    @PostMapping("/updateTboutLine")
    public ResultResponse updateTboutLine(TbOutline tbOutline){
        return tbOutlineService.updateTboutLine(tbOutline);
    }

    /***
     * @description 删除某一个大纲
     * @params [listParamVo]
     */
    @PostMapping("/deleteTboutLine")
    public ResultResponse deleteTboutLine(Long outLineId){
        return tbOutlineService.deleteTboutLine(outLineId);
    }

    @PostMapping("/uploadOutline")
    public ResultResponse uploadOutline(MultipartFile file) {
        return ResultResponse.SUCCESS(ossUploadTemplate.uploadFileObjectStorage(file));
    }
}

